package net.lab1024.sa.admin.module.yitihua.service;

import net.lab1024.sa.admin.module.yitihua.dao.Cfs119CompoundDao;
import net.lab1024.sa.admin.module.yitihua.domain.entity.Cfs119Compound;
import net.lab1024.sa.admin.module.yitihua.domain.form.Cfs119CompoundAddForm;
import net.lab1024.sa.admin.module.yitihua.domain.form.Cfs119CompoundQueryForm;
import net.lab1024.sa.admin.module.yitihua.domain.form.Cfs119CompoundUpdateForm;
import net.lab1024.sa.admin.module.yitihua.domain.vo.Cfs119CompoundVO;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 一体化平台小区信息 Service
 *
 * @Author cfsjiazy
 * @Date 2025-09-12 14:11:04
 * @Copyright  
 */

@Service
public class Cfs119CompoundService {

    @Resource
    private Cfs119CompoundDao cfs119CompoundDao;

    /**
     * 分页查询
     */
    public PageResult<Cfs119CompoundVO> queryPage(Cfs119CompoundQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<Cfs119CompoundVO> list = cfs119CompoundDao.queryPage(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);
    }

    /**
     * 添加
     */
    public ResponseDTO<String> add(Cfs119CompoundAddForm addForm) {
        Cfs119Compound cfs119CompoundEntity = SmartBeanUtil.copy(addForm, Cfs119Compound.class);
        cfs119CompoundDao.insert(cfs119CompoundEntity);
        return ResponseDTO.ok();
    }

    /**
     * 更新
     *
     */
    public ResponseDTO<String> update(Cfs119CompoundUpdateForm updateForm) {
        Cfs119Compound cfs119CompoundEntity = SmartBeanUtil.copy(updateForm, Cfs119Compound.class);
        cfs119CompoundDao.updateById(cfs119CompoundEntity);
        return ResponseDTO.ok();
    }

    /**
     * 批量删除
     */
    public ResponseDTO<String> batchDelete(List<String> idList) {
        if (CollectionUtils.isEmpty(idList)){
            return ResponseDTO.ok();
        }

        cfs119CompoundDao.deleteBatchIds(idList);
        return ResponseDTO.ok();
    }

    /**
     * 单个删除
     */
    public ResponseDTO<String> delete(String id) {
        if (null == id){
            return ResponseDTO.ok();
        }

        cfs119CompoundDao.deleteById(id);
        return ResponseDTO.ok();
    }

    public void addBatch(List<Cfs119Compound> list) {
        cfs119CompoundDao.insertBatch(list);
    }

    public List<Cfs119CompoundVO> queryByCommunityId(String communityId) {
        return cfs119CompoundDao.queryByCommunityId(communityId);
    }
}
